<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="Access-Control-Allow-Origin" content="ttp://127.0.0.1:5500">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="../css/public.css" media="all">
</head>
<body>
    <div class="layuimini-container">
        <div class="layuimini-main">
            <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>

            <script type="text/html" id="currentTableBar">
                <a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="edit">编辑</a>
                <a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete" lay-event="delete">删除</a>
            </script>
        </div>
    </div>

</body>
<script src="../lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form', 'table'], function () {
        var $ = layui.jquery,
            form = layui.form,
            table = layui.table;
    
            $.ajaxSetup({
            // 发送cookie
            xhrFields: {
                withCredentials: true
            }
        })
        var data = JSON.parse(localStorage.getItem("PrescriptionItem"));
        console.log(data);
        table.render({
            elem: '#currentTableId',
            url: 'http://localhost:8080/demo/prescriptionItem/selectPrescriptionItemByPreId?preId='+data.id,
            toolbar: '#toolbarDemo',
            title:'处方列表',
            defaultToolbar: ['filter', 'exports', 'print', {
                title: '提示',
                layEvent: 'LAYTABLE_TIPS',
                icon: 'layui-icon-tips'
            }],
            cols: [[
                {type: "checkbox", width: 50},
                {field: 'id', title: 'ID', width: 80, unresize: true, sort: true },
                {field: 'drugId', width: 120, title: '药品id',sort: true },
                {field: 'preId', width: 120, title: '处方id',sort: true },
                {field: 'drugName', width: 120, title: '药品名称'},
                {field: 'drugUnit', width: 120, title: '药品单位'},
                {field: 'drugAmount', width:120, title: '药品数量'},
                {field: 'drugPrice', width: 120, title: '单药品总价', sort: true},
                {field: 'createDate', width: 135, title: '建档时间', sort: true},
                {title: '操作', minWidth: 120, toolbar: '#currentTableBar', align: "center"}
            ]],
            page: true,
        });

        table.on('tool(currentTableFilter)', function(obj){


        });
    });
</script>
</html>